<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="bill" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:outputStylesheet library="css" name="pharmacyA4.css"/>
        <div class="posbill noBorder summeryBorder">

            <div class="institutionName">
                <h:outputLabel value="#{cc.attrs.bill.creater.department.printingName}"/>
            </div>
            <div class="institutionContact" >
                <div>
                    <h:outputLabel value="#{cc.attrs.bill.creater.department.address}"/>
                </div>
            </div>

            <div class="headingBill">
                <h:outputLabel value="PURCHASE BILL"   />                           
            </div>


            <div >
                <h:panelGrid columns="4" class="poDetail" >    
                    <h:outputLabel value="Purchase Date"/>
                    <h:outputLabel value="#{cc.attrs.bill.createdAt}">
                        <f:convertDateTime pattern="dd MM yyyy"/>
                    </h:outputLabel>

                    <h:outputLabel value="Direct GRN No"/>
                    <h:outputLabel value="#{cc.attrs.bill.deptId}"/>

                    <h:outputLabel value="Invoice Date"/>
                    <h:outputLabel value="#{cc.attrs.bill.invoiceDate}">
                        <f:convertDateTime pattern="dd MM yyyy"/>
                    </h:outputLabel>

                    <h:outputLabel value="Invoice No"/>  
                    <h:outputLabel value="#{cc.attrs.bill.invoiceNumber}"/> 

                    <h:outputLabel value="Supplier"/>
                    <h:outputLabel value="#{cc.attrs.bill.fromInstitution.name}"/>

                    <h:outputLabel value="Purchase Date"/>
                    <h:outputLabel value="#{cc.attrs.bill.createdAt}">
                        <f:convertDateTime pattern="dd MM yyyy"/>
                    </h:outputLabel>
                </h:panelGrid>
            </div>


            <div >
                <p:spacer height="15px"/>
                <p:dataTable rowIndexVar="rowIndex" styleClass="noBorder normalFont" value="#{cc.attrs.bill.billItems}" var="bip" >

                    <p:column>
                        <f:facet name="header">Item</f:facet>
                        <h:outputText value="#{bip.item.name}" ></h:outputText>
                        <h:outputText value=" (#{bip.item.code})" ></h:outputText>
                    </p:column>
                    <p:column >
                        <f:facet name="header">Expiry</f:facet>
                        <h:outputLabel value="#{bip.pharmaceuticalBillItem.doe}">
                            <f:convertDateTime pattern="dd MM yyyy"/>
                        </h:outputLabel>
                    </p:column>                                 

                    <p:column styleClass="shortNumericColumn">
                        <f:facet name="header">QTY</f:facet>
                            #{bip.pharmaceuticalBillItem.qty}
                    </p:column>

                    <p:column styleClass="shortNumericColumn">
                        <f:facet name="header">Free</f:facet>
                            #{bip.pharmaceuticalBillItem.freeQty}
                    </p:column>
                    <p:column styleClass="shortNumericColumn">
                        <f:facet name="header">P. Rate</f:facet>
                        <h:outputLabel value="#{bip.pharmaceuticalBillItem.purchaseRate}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column styleClass="shortNumericColumn">
                        <f:facet name="header">Last P.R.</f:facet>
                        <h:outputLabel value="#{bip.pharmaceuticalBillItem.lastPurchaseRate}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column styleClass="averageNumericColumn">
                        <f:facet name="header">P. Value</f:facet>
                        <h:outputLabel value="#{bip.pharmaceuticalBillItem.purchaseRate*bip.pharmaceuticalBillItem.qty}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:column styleClass="shortNumericColumn">
                        <f:facet name="header">Re. Rate</f:facet>
                        <h:outputLabel value="#{bip.pharmaceuticalBillItem.retailRate}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    
                    <p:column styleClass="averageNumericColumn">
                        <f:facet name="header">Re. Value</f:facet>
                        <h:outputLabel value="#{bip.pharmaceuticalBillItem.retailRate*(bip.pharmaceuticalBillItem.qty + bip.pharmaceuticalBillItem.freeQty )}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    
                    <p:column rendered="#{webUserController.hasPrivilege('PharmacyPurchaseWh')}">
                        <f:facet name="header">Wholesale Price</f:facet>
                        <h:outputLabel value="#{bip.pharmaceuticalBillItem.wholesaleRate}">
                            <f:convertNumber pattern="#,##0.00" />
                        </h:outputLabel>
                    </p:column>
                    <p:columnGroup type="footer">
                        <p:row>
                            <p:column colspan="6" footerText="Total"/>
                            <p:column footerText="#{0-cc.attrs.bill.total}" style="text-align: right;">
                                <f:facet name="footer">
                                    <h:outputLabel value="#{0-cc.attrs.bill.total}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            <p:column ></p:column>
                            <p:column footerText="#{0-cc.attrs.bill.saleValue}" style="text-align: right;">
                                <f:facet name="footer">
                                    <h:outputLabel value="#{0-cc.attrs.bill.total}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>
                            
                        </p:row>
                        <p:row rendered="#{cc.attrs.bill.tax!=0}">
                            <p:column colspan="9" footerText="Tax"/>
                            <p:column footerText="#{cc.attrs.bill.tax}">
                                <f:facet name="footer">
                                    <h:outputLabel value="#{cc.attrs.bill.tax}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>

                        </p:row>
                        <p:row rendered="#{cc.attrs.bill.discount!=0}">
                            <p:column colspan="9" footerText="Discount"/>
                            <p:column footerText="#{0-cc.attrs.bill.discount}">
                                <f:facet name="footer">
                                    <h:outputLabel value="#{0-cc.attrs.bill.discount}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>

                        </p:row>
                        <p:row rendered="#{cc.attrs.bill.total!=cc.attrs.bill.netTotal}">
                            <p:column colspan="9" footerText="Net Total"/>
                            <p:column footerText="#{0-cc.attrs.bill.netTotal}">
                                <f:facet name="footer">
                                    <h:outputLabel value="#{0-cc.attrs.bill.netTotal}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </f:facet>
                            </p:column>

                        </p:row>
                    </p:columnGroup>
                </p:dataTable>
            </div>

            <div class="preparedBy">
                <h:outputLabel value="Prepared By : #{cc.attrs.bill.creater.webUserPerson.nameWithTitle}"/>

            </div>

            <div >
                <h:outputLabel value="Received By : "/>
            </div>

            <hr/>
            <div >

                <h4 style="color: #000000; text-align: center " >
                    <h:outputLabel value="Payment Voucher" style="text-decoration: underline;"/>
                </h4>


                <div>
                    <h:outputLabel value="Date :"  style="position: relative; left: 70%;" />
                    <h:outputLabel value="Payee : " style="text-align: right!important;"/>
                    <h:outputLabel value="#{cc.attrs.bill.fromInstitution.name}"/>
                </div>
                <div>
                    <br></br>
                    <h:outputLabel value="Prepared By :" /> 
                    <h:outputLabel value="................................................................."/>
                    <br></br>                
                    <br></br>         
                    <h:outputLabel value="Approved By :"/>
                    <h:outputLabel value="................................................................."/>
                    <br></br>                                      
                    <br></br>
                    <h:outputLabel value="Authorized By :"/>
                    <h:outputLabel value="................................................................"/>
                    <br></br>
                    <br></br>

                    <h:outputLabel value="Cheque No :"/>
                    <h:outputLabel value="...................................................................."/>
                    <h:outputLabel value="Amount : Rs. ................" style="position: absolute; left: 70%;"/>
                    <br></br>
                    <br></br>                    
                    <h:outputLabel value="Received with thanks sum of Rupees  .................................................................................................................................................. "/>
                    <h:outputLabel value="#{cc.attrs.bill.creater.institution.name}"></h:outputLabel>
                    <br></br>

                    <!--                    <div >-->

                    <!--<h:outputLabel value="Date :"  style="position: relative; left: 70%;" />-->
                    <!--                        <br/>-->
                    <!--                        <h:outputLabel value="Amount : Rs. " style="font-weight: bold;position: relative; left: 70%;"/>-->
                    <!--                        <h:outputLabel value="#{0-cc.attrs.bill.netTotal}" style="font-weight: bold;position: relative; left: 71%;">-->
                    <!--<f:convertNumber pattern="#,##0.00" />-->
                    <!--                        </h:outputLabel>-->
                    <!--                        <br/>-->
                    <div>
                        <h:outputLabel value="Stamp : " style="position: relative; left: 70%; "/>
                        <div style="position: relative; border: 1px black dashed!important;height: 60px;width: 50px; left: 75%;">
                        </div>
                        <!--                        <h:outputLabel value="Stamp " style="position: relative; left: 70%;"/>-->
                        <!--                        <br></br>-->
                        <h:outputLabel value="Date : " style="position: relative; left: 70%;"/>
                        <br></br>
                        <h:outputLabel value="Name : " style="position: relative; left: 70%;"/>
                    </div>
                </div>

            </div>

            <!--            <hr/>
                        <div>
                            <div style="position: absolute; left: 70%;">
                                <h:outputLabel value="Date : ...................." />
                            </div>
                            <h4 style="color: #000000;">
                                Payment Voucher
                            </h4>
            
                            <h:panelGrid columns="2" styleClass="poDetail">
                                <h:outputLabel value="Payee : "/>
                                <h:outputLabel value="#{cc.attrs.bill.fromInstitution.name}"/>
                                <h:outputLabel value="Prepaired By : "/>
                                <h:outputLabel value="........................."/>
                                <h:outputLabel value="Approved By : "/>
                                <h:outputLabel value="........................."/>
                                <h:outputLabel value="Authorized By : "/>
                                <h:outputLabel value="........................."/>
                                <h:outputLabel value="Check No : "/>
                                <h:outputLabel value="........................."/>
                                <h:outputLabel value="Amount : "/>
                                <h:outputLabel value="........................."/>
                                <h:outputLabel value="Received with thanks sum of Rupees  : "/>
                                <h:outputLabel value="...................................."/>
                            </h:panelGrid>
            
            
                        </div>-->
        </div>
    </cc:implementation>
</html>
